<template>
    <div class="search-song-Lists">
        <content-list :contentList="albumDatas"></content-list>
    </div>
</template>

<script>
    import ContentList from "../components/ContentList";
    import { getSongListOfLikeTitle } from "../utils/index";
    import axios from "axios";
    import { Toast } from 'vant';

    export default {
        name: "SearchSongLists",
        components: {
            ContentList,
        },
        data() {
            return {
                albumDatas: [],
            };
        },
        mounted() {
            this.getSearchList();
        },
        methods: {
            getSearchList() {
                if (!this.$route.query.keywords) {
                    Toast("您输入的内容为空");
                } else {
                    axios.get("http://localhost:8888/songList/likeTitle",{params: {title:this.$route.query.keywords}}).then(res=>{
                        // this.collectList.push(res.data); this.albumDatas = res;
                        if (res.data){
                            this.albumDatas = res;
                        }else {
                            Toast("暂无该歌曲内容");
                        }
                    }).catch(err=>{
                            console.log(err)
                        }
                    )
                    //songList/likeTitle?title=${keywords}
                    // getSongListOfLikeTitle(this.$route.query.keywords).then((res) => {
                    //     if (res) {
                    //         this.albumDatas = res;
                    //     } else {
                    //         Toast("暂无该歌曲内容");
                    //     }
                    // });
                }
            },
        },
    }
</script>

<style lang="scss" scoped>

</style>
